package com.easy.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.CacheControl;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.concurrent.TimeUnit;

@Configuration
public class LocalFileWebConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 添加自定义路径（本地磁盘路径）
        registry.addResourceHandler("/file/**")
                .addResourceLocations("file:D:/upload/")
                .setCacheControl(CacheControl.maxAge(1, TimeUnit.HOURS));
    }
}